﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using Model;
using BLL;
public partial class association_intro : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadLeft();
        }
    }

    private void LoadLeft()
    {
        BllAss bll = new BllAss();
        Blladdr bll1 = new Blladdr();
        var list = bll.GetList(c => c.parentId == 0, true, c => c.sort);
        StringBuilder sb = new StringBuilder();
       
        for (int i = 0; i < list.Count; i++)
        {
            tb_ass obj = list[i];
            string name = obj.name;
            string id=obj.id.ToString();
            tb_addr addr = bll1.GetSingle(c => c.ass == obj.name);
            string addrs = addr.addr.Length > 8 ? addr.addr.Substring(0, 8) : addr.addr;
            string phone = addr.phone;
            string src = obj.src;
           
            sb.Append(string.Format(@"<li onclick='getContent({5})'>
                    <div class='s1'>
                        <img src='img/association_intro/{0}.jpg' /></div>
                    <div class='s2'>
                        <span class='sp1'>{1}</span> <span class='sp2'>地址：{2}..</span> <span class='sp2'>
                            电话：{3}</span>
                    </div>
                    <div class='s3'>
                        <img src='{4}' /></div>
                </li>", i + 1, name, addrs, phone, src,id));
            
        }
        left.Text = sb.ToString();
        right.Text = list[0].content;
    }
}